package com.catmiw.stock.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import com.catmiw.stock.dao.StockPriceMapper;
import com.catmiw.stock.domain.StockPrice;

public class StockPriceServiceImpl implements StockPriceService {

	public int insertAll(List<StockPrice> ins) {
		SqlSession session=SessionFactory.getInstance().getSession();
		StockPriceMapper cm=session.getMapper(StockPriceMapper.class);
		int count=0;
		
		for (StockPrice icm:ins){
			cm.insert(icm);
			count++;
		}
		session.commit();
		session.close();
		
		return count;
	}

	public void deleteAll() {
		SqlSession session=SessionFactory.getInstance().getSession();
		StockPriceMapper cm=session.getMapper(StockPriceMapper.class);
		cm.deleteAll();
		session.commit();
		session.close();
	}

}
